﻿#include "SetLanguageCommand.h"

#include "../../Setting/SettingManager.h"
#include "../../../Memory/GameData.h"

bool SetLanguageCommand_onExecute(const fast_io::vector<std::u8string>& args) {
	if (args.size() != 2)
		return false;

	int languageget{};
	auto& lang = args[1];

	if (lang == u8"0" || lang == u8"en_US") {
		SettingManager::languageget = 0;
		SettingManager::language = u8"en_US";
	} else if (lang == u8"1" || lang == u8"zh_CN") {
		SettingManager::languageget = 1;
		SettingManager::language = u8"zh_CN";
	} else if (lang == u8"2" || lang == u8"zh_HK" || lang == u8"zh_SG" || lang == u8"zh_TW" || lang == u8"zh_ZA") {
		SettingManager::languageget = 2;
		if (lang == u8"2")
			SettingManager::language = u8"zh_HK";
		else
			SettingManager::language = lang;
	} else if (lang == u8"3" || lang == u8"ja_JP") {
		SettingManager::languageget = 3;
		SettingManager::language = u8"ja_JP";
	} else
		return false;

	C_GuiData::displayClientMessageC(Utils::TextColor::LIGHT_PURPLE,
									 u8"[Helium] ",
									 Utils::TextColor::YELLOW,
									 u8"Set Language to : ",
									 SettingManager::language);

	return true;
}

ICommand SetLanguageCommand{u8"setlanguage",
							u8".setlanguage [<language>, <number>]",
							{u8"Set Language", u8"设置语言", u8"設置語言", u8"言語を設定する"},
							{},
							fast_io::vector<aliasList_struct>{
								aliasList_struct{stringview_Object{u8"en_US", nullptr}},
								aliasList_struct{stringview_Object{u8"zh_CN", nullptr}},
								aliasList_struct{stringview_Object{u8"zh_HK", nullptr}},
								aliasList_struct{stringview_Object{u8"zh_SG", nullptr}},
								aliasList_struct{stringview_Object{u8"zh_TW", nullptr}},
								aliasList_struct{stringview_Object{u8"zh_ZA", nullptr}},
								aliasList_struct{stringview_Object{u8"ja_JP", nullptr}},
								aliasList_struct{stringview_Object{u8"0", nullptr}},
								aliasList_struct{stringview_Object{u8"1", nullptr}},
								aliasList_struct{stringview_Object{u8"2", nullptr}},
								aliasList_struct{stringview_Object{u8"3", nullptr}},
							},  // If empty must use fast_io::vector<aliasList_struct>{}
							nullptr,
							&SetLanguageCommand_onExecute};